<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common :: common('修改密码')">
</head>
<form id="passwordForm" action="/sys/user/changePassword">
	<div class="box-body">
		<div class="form-group">
			<label>原密码 </label><input type="password" name="originalPassword"
				class="form-control " placeholder="原密码">
		</div>
		<div class="form-group">
			<label>新密码 </label><input type="password" name="password"
				class="form-control" placeholder="新密码">
		</div>
		<div class="form-group">
			<label>重新输入 </label><input type="password" name="retypePassword"
				class="form-control" placeholder="重新输入密码">
		</div>
	</div>
	<!-- /.box-body -->
	<div class="box-footer">
		<div class="pull-right">
			<button type="submit" class="btn btn-success">
				<i class="fa fa-floppy-o" aria-hidden="true"></i> 保存
			</button>
		</div>
	</div>
	<!-- /.box-footer -->
</form>
<script type="text/javascript">
	$(function() {
		$('#passwordForm').bootstrapValidator({
			message : '这个值是无效的',
			feedbackIcons : {
				valid : 'fa fa-check',
				invalid : 'fa fa-remove',
				validating : 'fa fa-refresh'
			},
			fields : {
				originalPassword : {
					validators : {
						notEmpty : {}
					}
				},
				password : {
					validators : {
						notEmpty : {},
						identical : {
							field : 'retypePassword',
							message : '这两个密码不匹配'
						}
					}
				},
				retypePassword : {
					validators : {
						notEmpty : {},
						identical : {
							field : 'password',
							message : '这两个密码不匹配'
						}
					}
				}
			}
		}).on('success.form.bv', function(e) {
			// Prevent form submission
			e.preventDefault();

			// Get the form instance
			var $form = $(e.target);

			// Get the BootstrapValidator instance
			var bv = $form.data('bootstrapValidator');

			// Use Ajax to submit form data
			$.post($form.attr('action'), $form.serialize(), function(result) {
				if (result.success) {
					layer.msg(result.msg, {
						icon : 6
					});
				} else {
					layer.msg(result.errorMsg, {
						icon : 5
					});
				}
			}, 'json');
		});
	});
</script>
</html>